import Vue from 'vue'
import VueRouter from 'vue-router'
// import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/login',
  },
  {
    path: '/login',
    component: () => import('../views/Login.vue'),
  },
  {
    path: '/register',
    component: () => import('../views/Register.vue'),
  },
  {
    path: '/admin',
    component: () => import('../views/Admin.vue'),
    redirect: '/admin/homestay',
    children:[
      {
        path: '/admin/homestay',
        component: () => import('../views/Admin/Homestay.vue'),
      },
      {
        path: '/admin/users',
        component: () => import('../views/Admin/Users.vue'),
      },
      {
        path: '/admin/home',
        component: () => import('../views/Admin/PageList.vue'),
      }
    ]
  },

  {
    path: '/index',
    component: () => import('../views/Index.vue'),
    redirect: '/index/home',
    children:[
      {
        path: '/index/home',
        component: () => import('../views/Index/Home.vue'),
      },
      {
        path: '/index/about',
        component: () => import('../views/Index/About.vue'),
      },
      {
        path: '/index/info',
        component: () => import('../views/Index/Info.vue'),
      },
      {
        name: 'detail',
        path: '/index/detail/:id',
        component: () => import('../views/Index/Detail.vue'),
      },
      {
        path: '/index/online',
        component: () => import('../views/Index/Online.vue'),
      },
      {
        path: '/index/news',
        component: () => import('../views/Index/News.vue'),
      },
      {
        path: '/index/mine',
        component: () => import('../views/Index/Mine.vue'),
      },
    ]
  },
  

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
